// 手机号校验
export function isPhoneValid(phone: string): boolean {
    const phoneExp = /^1[3456789]\d{9}$/;
    return phoneExp.test(phone);
}



// 银行卡校验
export function isBankCardValid(bankCard: string): boolean {
    const bankCardExp = /^\d{16,19}$/;
    return bankCardExp.test(bankCard);
}


// 将银行卡变为******
export function maskCardNumber(cardNumber: string) {
    return cardNumber.replace(/^(\d{4})\d+(\d{4})$/, '$1********$2');
}

//验证邮箱
export function isEmailValid(email) {
    if (!(/^\w+@[a-zA-Z0-9]{2,10}(?:\.[a-z]{2,4}){1,3}$/.test(email))) {
        return false;
    } else {
        return true
    }
}


// 隐藏手机号
export const maskPhone = (phone) => {
    if (phone?.length !== 11) return phone;
    return phone.slice(0, 3) + '****' + phone.slice(7);
};